package com.example.shw

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.widget.CompoundButton
import android.widget.LinearLayout
import android.widget.Switch
import android.widget.ToggleButton

class ToggleButtonActivity : AppCompatActivity(){
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_toggle)
        val toggle = findViewById<ToggleButton>(R.id.toggle)
        val switcher =  findViewById<Switch>(R.id.switcher)
        val test = findViewById<LinearLayout>(R.id.testlinearlayout)
        val listener = CompoundButton.OnCheckedChangeListener{button,isChecked ->
            if (isChecked){
                test.orientation = LinearLayout.VERTICAL
                toggle.isChecked = true
                switcher.isChecked = true
            }else{
                test.orientation = LinearLayout.HORIZONTAL
                toggle.isChecked = false
                switcher.isChecked = false
            }
        }
        toggle.setOnCheckedChangeListener(listener)
        switcher.setOnCheckedChangeListener(listener)
    }
}